package com.oig.sys.workflow.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

@Schema
@Getter
@Setter
@ToString
public class FlowConfigDto {

	@Schema(description = "ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "参数错误,id不能为空", groups= {GroupEdit.class})
	private Integer id;

	@Schema(description = "系统编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，系统编码不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String sysCode;
	@Schema(description = "业务编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，业务编码不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String bizType;

	@Schema(description = "流程编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，流程编码不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String flowCode;
	@Schema(description = "流程名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，流程名称不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String flowName;
	@Schema(description = "三方流程类型")
	private String type="0";
	@Schema(description = "流程表单json", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，流程表单json不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String formJson;
	@Schema(description = "自定义节点json")
	private String nodeJson;

	@Schema(description = "回调通知地址", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	//@NotEmpty(message = "参数错误，回调通知地址不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String notifyUrl;

	@Schema(description = "流程表单字段列表", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "流程表单字段列表必填", groups={GroupAdd.class, GroupEdit.class})
	@Size(min = 1,message = "至少一个表单字段", groups={GroupAdd.class, GroupEdit.class})
	@Valid
	private List<FlowFormDto> flowFormDtoList;


	@Schema(description = "所属租户id")
	private Integer tenantId;
	@Schema(description = "所属租户名称")
	private String tenantName;

	@Hidden
	@Schema(description = "创建人id")
	private Integer createUserId;
	@Hidden
	@Schema(description = "创建人")
	private String createUserName;
	@Hidden
	@Schema(description = "创建时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;
	@Hidden
	@Schema(description = "最后更新人id")
	private Integer lastUpdateId;
	@Hidden
	@Schema(description = "最后更新人")
	private String lastUpdateName;
	@Hidden
	@Schema(description = "最后更新时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastUpdateTime;
}
